package org.dzq.designmode.proxy.cglibproxy;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @ClassName: CglibInterceptor
 * @Package: org.dzq.designmode.proxy.cglibproxy
 * @author: 越
 * @date: 2023/6/17 15:10
 * @Description:
 */
public class CglibInterceptor implements MethodInterceptor {

    public void sleep(){
        System.out.println("吃饱了就睡");
    }

    @Override
    public Object intercept(Object proxyObject, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
        Object result = methodProxy.invokeSuper(proxyObject,args);
        sleep();
        return result;
    }
}
